﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Xts
{
    namespace XInterBank
    {
        namespace TradingClient
        {
            [Serializable]
            public class XSendOrderRspEventArgs : EventArgs
            {
                private XSendOrderRsp x_rsp;
                private XOrderDelivery_SendOrder_Cookies x_cookies;

                public XSendOrderRsp Rsp 
                {
                    get { return x_rsp; }
                    set { x_rsp = value; }
                }

                public XOrderDelivery_SendOrder_Cookies Cookies
                {
                    get { return x_cookies; }
                    set { x_cookies = value; }
                }

                public XSendOrderRspEventArgs(XSendOrderRsp rsp, XOrderDelivery_SendOrder_Cookies cookies)
                {
                    x_rsp = rsp;
                    x_cookies = cookies;
                }
            }

            [Serializable]
            public class XSendOrderCookiesEventArgs : EventArgs
            {
                private XOrderDelivery_SendOrder_Cookies x_cookies;
                public XOrderDelivery_SendOrder_Cookies Cookies
                {
                    get { return x_cookies; }
                    set { x_cookies = value; }
                }

                public XSendOrderCookiesEventArgs(XOrderDelivery_SendOrder_Cookies cookies)
                {
                    x_cookies = cookies;
                }
            }

            [Serializable]
            public class XCancelOrderRspEventArgs : EventArgs
            {
                private XCancelOrderRsp x_rsp;
                private XOrderDelivery_CancelOrder_Cookies x_cookies;

                public XCancelOrderRsp Rsp 
                { 
                    get { return x_rsp; }
                    set { x_rsp = value; }
                }

                public XOrderDelivery_CancelOrder_Cookies Cookies
                {
                    get { return x_cookies; }
                    set { x_cookies = value; }
                }

                public XCancelOrderRspEventArgs(XCancelOrderRsp rsp, XOrderDelivery_CancelOrder_Cookies cookies)
                {
                    x_rsp = rsp;
                    x_cookies = cookies;
                }
            }

            [Serializable]
            public class XCancelOrderCookiesEventArgs : EventArgs
            {
                private XOrderDelivery_CancelOrder_Cookies x_cookies;
                public XOrderDelivery_CancelOrder_Cookies Cookies
                {
                    get { return x_cookies; }
                    set { x_cookies = value; }
                }

                public XCancelOrderCookiesEventArgs(XOrderDelivery_CancelOrder_Cookies cookies)
                {
                    x_cookies = cookies;
                }
            }

            [Serializable]
            public class XBatchCancelOrderRspEventArgs : EventArgs
            {
                private XCancelOrderRsp[] x_rsp;
                private XOrderDelivery_BatchCancelOrder_Cookies x_cookies;

                public XCancelOrderRsp[] Rsp
                {
                    get { return x_rsp; }
                    set { x_rsp = value; }
                }

                public XOrderDelivery_BatchCancelOrder_Cookies Cookies
                {
                    get { return x_cookies; }
                    set { x_cookies = value; }
                }

                public XBatchCancelOrderRspEventArgs(XCancelOrderRsp[] rsp, XOrderDelivery_BatchCancelOrder_Cookies cookies)
                {
                    x_rsp = rsp;
                    x_cookies = cookies;
                }
            }

            [Serializable]
            public class XBatchCancelOrderCookiesEventArgs : EventArgs
            {
                private XOrderDelivery_BatchCancelOrder_Cookies x_cookies;
                public XOrderDelivery_BatchCancelOrder_Cookies Cookies
                {
                    get { return x_cookies; }
                    set { x_cookies = value; }
                }

                public XBatchCancelOrderCookiesEventArgs(XOrderDelivery_BatchCancelOrder_Cookies cookies)
                {
                    x_cookies = cookies;
                }
            }

            [Serializable]
            public class XAmiOrderDeliveryCallbackEventHandler : IXAmiOrderDeliveryCBHandler
            {
                public EventHandler<XSendOrderRspEventArgs> SendOrderRspReached;
                public EventHandler<XSendOrderCookiesEventArgs> FailureSendOrderReached;
                public EventHandler<XSendOrderRspEventArgs> SendMarketMakingOrderRspReached;
                public EventHandler<XSendOrderCookiesEventArgs> FailureSendMarketMakingOrderReached;
                public EventHandler<XCancelOrderRspEventArgs> CancelOrderRspReached;
                public EventHandler<XCancelOrderCookiesEventArgs> FailureCancelOrderReached;
                public EventHandler<XBatchCancelOrderRspEventArgs> BatchCancelOrderRspReached;
                public EventHandler<XBatchCancelOrderCookiesEventArgs> FailureBatchCancelOrderReached;

                public XAmiOrderDeliveryCallbackEventHandler() { }

                public void OnSendOrder(XSendOrderRsp rsp, XOrderDelivery_SendOrder_Cookies cookies)
                {
                    EventHandler<XSendOrderRspEventArgs> handler = SendOrderRspReached;
                    if (handler != null)
                        handler(this, new XSendOrderRspEventArgs(rsp, cookies));
                }

                public void OnFailureSendOrder(XOrderDelivery_SendOrder_Cookies cookies)
                {
                    EventHandler<XSendOrderCookiesEventArgs> handler = FailureSendOrderReached;
                    if (handler != null)
                        handler(this, new XSendOrderCookiesEventArgs(cookies));
                }

                public void OnSendMarketMakingOrder(XSendOrderRsp rsp, XOrderDelivery_SendOrder_Cookies cookies)
                {
                    EventHandler<XSendOrderRspEventArgs> handler = SendMarketMakingOrderRspReached;
                    if (handler != null)
                        handler(this, new XSendOrderRspEventArgs(rsp, cookies));
                }

                public void OnFailureSendMarketMakingOrder(XOrderDelivery_SendOrder_Cookies cookies) 
                {
                    EventHandler<XSendOrderCookiesEventArgs> handler = FailureSendMarketMakingOrderReached;
                    if (handler != null)
                        handler(this, new XSendOrderCookiesEventArgs(cookies));
                }

                public void OnCancelOrder(XCancelOrderRsp rsp, XOrderDelivery_CancelOrder_Cookies cookies)
                {
                    EventHandler<XCancelOrderRspEventArgs> handler = CancelOrderRspReached;
                    if (handler != null)
                        handler(this, new XCancelOrderRspEventArgs(rsp, cookies));
                }

                public void OnFailureCancelOrder(XOrderDelivery_CancelOrder_Cookies cookies)
                {
                    EventHandler<XCancelOrderCookiesEventArgs> handler = FailureCancelOrderReached;
                    if (handler != null)
                        handler(this, new XCancelOrderCookiesEventArgs(cookies));
                }

                public void OnBatchCancelOrder(XCancelOrderRsp[] rsp, XOrderDelivery_BatchCancelOrder_Cookies cookies)
                {
                    EventHandler<XBatchCancelOrderRspEventArgs> handler = BatchCancelOrderRspReached;
                    if (handler != null)
                        handler(this, new XBatchCancelOrderRspEventArgs(rsp, cookies));
                }

                public void OnFailureBatchCancelOrder(XOrderDelivery_BatchCancelOrder_Cookies cookies)
                {
                    EventHandler<XBatchCancelOrderCookiesEventArgs> handler = FailureBatchCancelOrderReached;
                    if (handler != null)
                        handler(this, new XBatchCancelOrderCookiesEventArgs(cookies));
                }
            }
        }
    }
}
